package com.ruoyi.LXHComplaint.service.impl;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.LXHComplaint.mapper.DocComplaintLXHMapper;
import com.ruoyi.LXHComplaint.domain.DocComplaintLXH;
import com.ruoyi.LXHComplaint.service.IDocComplaintLXHService;

/**
 * 个人投诉Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-16
 */
@Service
public class DocComplaintLXHServiceImpl implements IDocComplaintLXHService 
{
    @Autowired
    private DocComplaintLXHMapper docComplaintLXHMapper;

    /**
     * 查询个人投诉
     * 
     * @param complaintId 个人投诉主键
     * @return 个人投诉
     */
    @Override
    public DocComplaintLXH selectDocComplaintLXHByComplaintId(Long complaintId)
    {
        return docComplaintLXHMapper.selectDocComplaintLXHByComplaintId(complaintId);
    }

    /**
     * 查询个人投诉列表
     * 
     * @param docComplaintLXH 个人投诉
     * @return 个人投诉
     */
    @Override
    public List<DocComplaintLXH> selectDocComplaintLXHList(DocComplaintLXH docComplaintLXH)
    {
        // 强制设置为当前登录用户的投诉（无论前端传什么，都只能查自己的）
        docComplaintLXH.setUserId(SecurityUtils.getUserId());
        return docComplaintLXHMapper.selectDocComplaintLXHList(docComplaintLXH);
    }

    /**
     * 新增个人投诉
     * 
     * @param docComplaintLXH 个人投诉
     * @return 结果
     */
    @Override
    public int insertDocComplaintLXH(DocComplaintLXH docComplaintLXH)
    {
        // 获取当前登录用户ID并设置到docComplaint对象中
        docComplaintLXH.setUserId(SecurityUtils.getUserId());

        // 设置投诉状态为默认值1 待处理
        docComplaintLXH.setComplaintState("1");
        return docComplaintLXHMapper.insertDocComplaintLXH(docComplaintLXH);
    }

    /**
     * 修改个人投诉
     * 
     * @param docComplaintLXH 个人投诉
     * @return 结果
     */
    @Override
    public int updateDocComplaintLXH(DocComplaintLXH docComplaintLXH)
    {
        return docComplaintLXHMapper.updateDocComplaintLXH(docComplaintLXH);
    }

    /**
     * 批量删除个人投诉
     * 
     * @param complaintIds 需要删除的个人投诉主键
     * @return 结果
     */
    @Override
    public int deleteDocComplaintLXHByComplaintIds(Long[] complaintIds)
    {
        return docComplaintLXHMapper.deleteDocComplaintLXHByComplaintIds(complaintIds);
    }

    /**
     * 删除个人投诉信息
     * 
     * @param complaintId 个人投诉主键
     * @return 结果
     */
    @Override
    public int deleteDocComplaintLXHByComplaintId(Long complaintId)
    {
        return docComplaintLXHMapper.deleteDocComplaintLXHByComplaintId(complaintId);
    }
}
